﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Ue.CQRS.Samples.Repositories
{
    public interface IRepository<T>    
    {
        T this[Guid key] { get; set; }

        T GetOrAdd(Guid key, T entity);
        T GetOrAdd(Guid key, Func<Guid, T> addEntityFactory);

        void AddOrUpdate(Guid key, T entity);
        void AddOrUpdate(Guid key, Func<Guid, T> entityFactory);
        void AddOrUpdate(Guid key, Func<Guid, T> addEntityFactory, Func<Guid, T, T> updateEntityFactory);

        void Remove(Guid key);

        bool ContainsKey(Guid key);

        IEnumerable<T> FindBy(Expression<Func<T,bool>> predicate);

        IEnumerable<T> FindBy(Expression<Func<T, bool>> predicate, int skip, int count);

        IEnumerable<T> FindAll();
    }
}
